<?php
/**
 * FP_Logger class file
 * @package FP_Logging
 */

/**
 * This class handles the logging of various operations.
 * 
 * @package FP_Logging
 * @author Brad Dougherty <bdougherty@gmail.com>
 * @version 8.5.10
 * @license http://www.gnu.org/licenses/gpl.html GNU General Public License 3.0
 */
class FP_Logger {
	
	/**
	 * Database object reference
	 * @var FlickrPhotosetsDatabase
	 */
	private $_db;
	
	/**
	 * Constructor
	 * 
	 * @author Brad Dougherty <bdougherty@gmail.com>
	 * @param FlickrPhotosetsDatabase $db The FlickrPhotosetsDatabase object
	 */
	public function __construct($db) {
		$this->_db = $db;
	}
	
	/**
	 * Logs an install of the application.
	 * 
	 * @author Brad Dougherty <bdougherty@gmail.com>
	 * @param int $uid The uid of the adding user
	 * @return boolean True if the query was successful
	 */
	public function install($uid, $success = true, $extra = '') {
		return $this->_db->log($uid, 'authorize', $success, $extra);
	}
	
	/**
	 * Logs a news feed notification.
	 * 
	 * @author Brad Dougherty <bdougherty@gmail.com>
	 * @param int $uid The uid of the user being notified
	 * @param string $type The type of notification, either photos or photosets
	 * @param boolean $success Whether the notification was a success
	 * @param string $extra Extra information about the notification
	 * @return boolean True if the query was successful
	 */
	public function notification($uid, $type, $success, $extra = '') {
		$type = ($type == 'photosets') ? 'set_story' : 'photo_story';
		return $this->_db->log($uid, $type, $success, $extra);
	}
	
	/**
	 * Logs a removal of the application.
	 * 
	 * @author Brad Dougherty <bdougherty@gmail.com>
	 * @param int $uid The uid of the removing user
	 * @param boolean $success Whether the notification was a success
	 * @param string $extra Extra information about the notification
	 * @return boolean True if the query was successful
	 */
	public function remove($uid, $success = true, $extra = '') {
		return $this->_db->log($uid, 'remove', $success, $extra);
	}
	
	/**
	 * Logs the addition of a tag or tags to a photo.
	 * 
	 * @author Brad Dougherty <bdougherty@gmail.com>
	 * @param int $uid The uid of the user
	 * @param int $pid The photo id
	 * @param string $tags The list of tags added
	 * @return boolean True if the query was successful
	 */
	public function tag_add($uid, $pid, $tags) {
		$this->_db->log($uid, 'tag_add', true, $pid.':'.$tags);
	}
	
	/**
	 * Logs the removal of a tag.
	 * 
	 * @author Brad Dougherty <bdougherty@gmail.com>
	 * @param int $uid The uid of the user
	 * @param int $pid The pid of the photo
	 * @param int $tag_id The unique tag id
	 * @return boolean True if the query was successful
	 */
	public function tag_remove($uid, $pid, $tag_id) {
		$this->_db->log($uid, 'tag_remove', true, $pid.':'.$tag_id);
	}
	
	/**
	 * Logs a profile update.
	 * 
	 * @author Brad Dougherty <bdougherty@gmail.com>
	 * @param int $uid The uid of the updating user
	 * @return boolean True if the query was successful
	 */
	public function update($uid, $extra = '') {
		return $this->_db->log($uid, 'profile_update', true, $extra);
	}
	
}

?>